﻿using Abp.AutoMapper;
using Abp.Modules;
using Abp.Reflection.Extensions;
using DevM.Authorization;
using System;

namespace DevM
{
    [DependsOn(
        typeof(DevMCoreModule), 
        typeof(AbpAutoMapperModule))]
    public class DevMApplicationModule : AbpModule
    {
        public override void PreInitialize()
        {
            Configuration.Authorization.Providers.Add<DevMAuthorizationProvider>();
            //配置资源缓存固定8个小时
            Configuration.Caching.Configure("Resource", options =>
            {
                options.DefaultAbsoluteExpireTime = TimeSpan.FromHours(1);
            });
            Configuration.MultiTenancy.IsEnabled = true;
        }

        public override void Initialize()
        {
            var thisAssembly = typeof(DevMApplicationModule).GetAssembly();

            IocManager.RegisterAssemblyByConvention(thisAssembly);

            Configuration.Modules.AbpAutoMapper().Configurators.Add(
                // Scan the assembly for classes which inherit from AutoMapper.Profile
                cfg => cfg.AddMaps(thisAssembly)
            );
        }
    }
}
